﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Documents;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Windows.Controls;
using RandomSelectTool.Resources.SubPage;
using System.Windows.Navigation;
using RandomSelectTool.Resources.Components.ViewModel;
using System.Windows.Media.Effects;
using System.Windows.Media;

namespace RandomSelectTool
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow
    {
        private bool isDragging = false;
        private Point startPoint;
        private Point startWindowPoint;

        public MainWindow()
        {
            InitializeComponent();

        }

        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            // 鼠标移动时的操作
        }

        private void OnLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            // 鼠标左键按下时的操作
        }

        private void OnLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            // 鼠标左键释放时的操作
        }


        private void Button_MouseEnter(object sender, MouseEventArgs e)
        {
            // 悬停时突出效果
            Button button = sender as Button;
            DropShadowEffect dropShadowEffect = new DropShadowEffect
            {
                Color = Colors.Gray,
                Direction = 270,
                ShadowDepth = 2,
                Opacity = 0.5,
                BlurRadius = 5
            };
            button.Effect = dropShadowEffect;
        }

        private void Button_MouseLeave(object sender, MouseEventArgs e)
        {
            // 离开时恢复效果
            Button button = sender as Button;
            button.Effect = null;
        }

        private void Button_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // 按下时凹陷效果
            Button button = sender as Button;
            DropShadowEffect dropShadowEffect = new DropShadowEffect
            {
                Color = Colors.Gray,
                Direction = 270,
                ShadowDepth = 2,
                Opacity = 0.5,
                BlurRadius = 5
            };
            button.Effect = dropShadowEffect;
        }

        private void Button_MouseUp(object sender, MouseButtonEventArgs e)
        {
            // 松开时恢复突出效果
            Button button = sender as Button;
            DropShadowEffect dropShadowEffect = new DropShadowEffect
            {
                Color = Colors.Gray,
                Direction = 270,
                ShadowDepth = 2,
                Opacity = 0.5,
                BlurRadius = 5
            };
            button.Effect = dropShadowEffect;
        }

        private void MinimizeButton_Click(object sender, RoutedEventArgs e)
        {
            // 最小化窗口
            this.WindowState = WindowState.Minimized;
        }

        private void CloseButton_Click(object sender, RoutedEventArgs e)
        {
            // 关闭窗口
            this.Close();
        }
        private void StudetCheckInButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建 StudentCheckIn 页面的实例
            StudentCheckIn studentCheckInPage = new StudentCheckIn();

            // 在主窗口的框架或容器中显示 StudentCheckIn 页面
            MainPageFrame.Content = studentCheckInPage;
        }

        private void StudetClassButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建 StudentCheckIn 页面的实例
            StudentClass studentClassPage = new StudentClass();

            // 在主窗口的框架或容器中显示 StudentCheckIn 页面
            MainPageFrame.Content = studentClassPage;
        }

        private void StudetInfomationButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建 StudentCheckIn 页面的实例
            StudetInfomation studentInfomationPage = new StudetInfomation();

            // 在主窗口的框架或容器中显示 StudentCheckIn 页面
            MainPageFrame.Content = studentInfomationPage;
        }

        private void TeacherHelpButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建 StudentCheckIn 页面的实例
            TeacherHelp teacherHelpPage = new TeacherHelp();

            // 在主窗口的框架或容器中显示 StudentCheckIn 页面
            MainPageFrame.Content = teacherHelpPage;
        }

        private void TeacherUsingButton_Click(object sender, RoutedEventArgs e)
        {
            // 创建 StudentCheckIn 页面的实例
            TeacherUsing teacherUsingPage = new TeacherUsing();

            // 在主窗口的框架或容器中显示 StudentCheckIn 页面
            MainPageFrame.Content = teacherUsingPage;
        }

        private void MainPageFrame_Navigated(object sender, NavigationEventArgs e)
        {
            
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            isDragging = true;
            startPoint = e.GetPosition(this);
        }

        private void Window_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            isDragging = false;
        }

        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            if (isDragging)
            {
                Point endPoint = e.GetPosition(this);
                double offsetX = endPoint.X - startPoint.X;
                double offsetY = endPoint.Y - startPoint.Y;

                Left += offsetX;
                Top += offsetY;

                startPoint = endPoint;
            }
        }
    }
}
